package com.easy.easy.Controller;

import com.easy.easy.Service.IAdminService;
import com.easy.easy.bean.Admin;
import com.easy.easy.bean.User;
import com.easy.easy.util.LayData;
import com.easy.easy.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("admin")
public class AdminController {
    @Autowired
    IAdminService adminService;

    @RequestMapping("list")
    @ResponseBody
    public LayData getlist(Page page, String text){
        List<Admin> list = adminService.getList(page,text);
        int count = adminService.getCount(text);
        return new LayData(count,list);
    }

    @RequestMapping("add")
    @ResponseBody
    public int add(Admin admin) {
            return adminService.add(admin);
    }
    @RequestMapping("edit")
    @ResponseBody
    public int edit(Admin admin) {
        return adminService.edit(admin);
    }
    @RequestMapping("delete")
    @ResponseBody
    public int delete(int adminid) {
        return adminService.delete(adminid);
    }

}
